
package com.idealighter.game.rank.manager;

import com.google.inject.Singleton;

import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.player.service.bo.PlayerRankBo;
import com.idealighter.game.rank.convert.RankConvert;
import com.idealighter.game.rank.dto.RankPlayerDto;
import com.idealighter.game.rank.message.ResGoldRankMsg;
import com.idealighter.game.rank.message.ResWinGoldRankMsg;
import com.idealighter.utils.check.EmptyUtil;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 银行消息管理 .
 * 
 * @date 2016年1月15日 下午4:11:26
 *
 */
@Singleton
public class RankMsgMgr {


  /**
   * 金币排行榜.
   * 
   * @param playerRankDomains 玩家列表.
   * @return 列表.
   */
  public ResMessage resGoldRankList(List<PlayerRankBo> playerRankDomains) {
    List<RankPlayerDto> dtos = RankConvert.INSTANCE.toRankPlayerDtos(playerRankDomains);

    ResGoldRankMsg msg = new ResGoldRankMsg();
    msg.setPlayers(dtos);

    return msg;
  }


  /**
   * 赢分榜.
   * 
   * @param playerRankDomains 玩家列表.
   * @return 列表.
   */
  public ResMessage resWinGoldRankList(List<PlayerRankBo> playerRankDomains) {
    List<RankPlayerDto> dtos = new ArrayList<>();

    ResWinGoldRankMsg msg = new ResWinGoldRankMsg();
    msg.setPlayers(dtos);

    if (EmptyUtil.listIsNotEmpty(playerRankDomains)) {
      for (Iterator<PlayerRankBo> iterator = playerRankDomains.iterator(); iterator.hasNext();) {
        PlayerRankBo bo = (PlayerRankBo) iterator.next();
        RankPlayerDto dto = RankConvert.INSTANCE.toRankPlayerDto(bo);
        dto.setGold(bo.getWinGold());
        dtos.add(dto);
      }
    }

    return msg;
  }

}
